// 利用本地存储实现的一个小型数据库助手
import GxDB from '@/utils/gxdb.js'

// 导入md5加密
import md5 from 'js-md5'

// 创建一个数据库实例
const db = new GxDB('vivodb').open()

// 创建admin   incmt 自动增长的主键
db.createTB(
  'gx_admin',
  { key: 'id', incmt: true },
  {
    avatar: require('@/assets/img/photo.png'),
    username: 'admin',
    nickname: '龚贤',
    mobile: '18579105168',
    password: md5('000000'),
    gender: 2,
    role: 1,
    pubdate: 12847328222134,
    state: 2
  }
)

// 创建 carousel
db.createTB(
  'gx_carousel',
  { key: 'id', incmt: true },
  [{
    orderid: 1,
    title: '网易',
    thumb: 'https://cube.elemecdn.com/6/94/4d3ea53c084bad6931a56d5158a48jpeg.jpeg',
    url: 'www.163.com',
    pubdate: 12847328222134,
    state: 1
  },
  {
    orderid: 12, 
    title: '百度',
    thumb: 'https://cube.elemecdn.com/6/94/4d3ea53c084bad6931a56d5158a48jpeg.jpeg',
    url: 'www.baidu.com',
    pubdate: 12847328222323,
    state: 2
  },
  {
    orderid: 3,
    title: '凤凰网',
    thumb: 'https://cube.elemecdn.com/6/94/4d3ea53c084bad6931a56d5158a48jpeg.jpeg',
    url: 'www.ifeng.com',
    pubdate: 1284732232334,
    state: 1
  }]
)

// 创建productcate
db.createTB(
  'gx_productcate',
  { key: 'id', incmt: true },
  [
    {
    title: '类别名称1',
    thumb: 'https://cube.elemecdn.com/6/94/4d3ea53c084bad6931a56d5158a48jpeg.jpeg',
    orderid: 1,
    state: 1
    },
    {
    title: '类别名称2',
    thumb: 'https://cube.elemecdn.com/6/94/4d3ea53c084bad6931a56d5158a48jpeg.jpeg',
    orderid: 1,
    state: 1
    },
    {
    title: '类别名称3',
    thumb: 'https://cube.elemecdn.com/6/94/4d3ea53c084bad6931a56d5158a48jpeg.jpeg',
    orderid: 1,
    state: 1
    },
  ]
)


// 创建user
db.createTB(
  'gx_user',
  { key: 'id', incmt: true },
  {
    username: 'test',
    nickname: '测试员'
  }
)

// 导出数据库实例
export default db
